/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.stemaini.utility;

import javax.swing.SpinnerNumberModel;

/**
 *
 * @author AdhiK
 */
public class SpinnerModel extends SpinnerNumberModel{
    private Double number;
    private Double max;
    private Double min;
    private Double step;

    public SpinnerModel(double number, double max, double min) {
        this.number = number;
        this.max = max;
        this.min = min;
        this.setMaximum(max);
        this.setMinimum(min);
    }

    @Override
    public Comparable getMaximum() {
        return this.max;
    }

    @Override
    public Comparable getMinimum() {
        return this.min;
    }

    @Override
    public Object getNextValue() {
        return new Double(number.doubleValue() + 1);
    }

    @Override
    public Number getNumber() {
        return this.number;
    }

    @Override
    public Object getPreviousValue() {
        return new Double(number.doubleValue() - 1);
    }

    @Override
    public Number getStepSize() {
        //return super.getStepSize();
        return step;
    }

    @Override
    public Object getValue() {
        return this.number;
    }

    @Override
    public void setMaximum(Comparable maximum) {
        this.max = (Double)maximum;
    }

    @Override
    public void setMinimum(Comparable minimum) {
        this.min = (Double)minimum;
    }

    @Override
    public void setStepSize(Number stepSize) {
        this.step = (Double)stepSize;
    }

    @Override
    public void setValue(Object value) {
        if (!(value instanceof Double)) {
            throw new IllegalArgumentException();
        } else {
            this.number = (Double) value;
            this.fireStateChanged();
        }
    }
    
    
    
}
